" vim:ft=vim

Execute(test-FloatermPrev-FloatermNext):
  FloatermNew
  let bufnr1 = bufnr('%')
  FloatermNew
  let bufnr2 = bufnr('%')
  FloatermNew
  let bufnr3 = bufnr('%')
  FloatermNew
  let bufnr4 = bufnr('%')

  Log '# Execute `:FloatermPrev'
    FloatermPrev
    AssertEqual bufnr3, bufnr('%')
    FloatermPrev
    AssertEqual bufnr2, bufnr('%')
    FloatermPrev
    AssertEqual bufnr1, bufnr('%')
    FloatermPrev
    AssertEqual bufnr4, bufnr('%')

  Log '# Execute `:FloatermNext'
    FloatermNext
    AssertEqual bufnr1, bufnr('%')
    FloatermNext
    AssertEqual bufnr2, bufnr('%')
    FloatermNext
    AssertEqual bufnr3, bufnr('%')
    FloatermNext
    AssertEqual bufnr4, bufnr('%')

  Log '# Kill the prev floaterm and execute `:FloatermPrev'
    FloatermHide " otherwise vim8 testing fails
    execute bufnr3 . 'FloatermKill'
    sleep 100m
    FloatermPrev
    AssertEqual bufnr2, bufnr('%')

  Log '# Kill the next floaterm and execute `:FloatermPrev'
    FloatermHide " otherwise vim8 testing fails
    execute bufnr4 . 'FloatermKill'
    sleep 100m
    FloatermNext
    AssertEqual bufnr1, bufnr('%')

  FloatermKill!
  stopinsert
